const caption = document.querySelector('.intro-content')

$(window).load(function () {
    $('header').addClass('move')
    anime(
        {
            //对每个子元素展示动画
            targets: caption.children,
            opacity: [0, 1],
            duration: 400,
            translateY: -50,
            direction: 'alternate',
            loop: false,
            easing: 'spring(1, 80, 10, 0)',
            delay: anime.stagger(100, {start: 200})
        }
    )
})
//切换夜间模式
$('span.check').click(function () {
     if ($('span.check').hasClass('active')) {
        $('span.check').css({'box-shadow': '0 0 2px 3px #006dfe'})
        $('*').removeClass('active')
    } else {
        $('*').addClass('active')
        $('span.check').css({'box-shadow': '0 0 2px 3px #006dfe'})
    }
    setTimeout(function () {
        $('span.check').css({
            'box-shadow':'unset'
        })
    },3000)

})

const staggeringOption = {
    delay: 300,
    opacity: [0, 1],
    duration: 300,
    easing: "ease-in-out",
    origin: "bottom"
};
ScrollReveal().reveal(".post-item", {...staggeringOption});

//汉堡按钮点击动画
const burger = document.querySelector('.burger')
const menu = document.querySelector('nav ul.menu')
const Menu_items = document.querySelectorAll('nav ul.menu li')
const burger_son = document.querySelectorAll('.burger span')
burger.addEventListener('click', () => {
    menu.classList.toggle('show')
    // 菜单项动画
    Menu_items.forEach((item, index) => {
        if (item.style.animation) {
            item.style.animation = "";
        } else {
            item.style.animation = `0.3s ease-in slideIn forwards ${index * 0.1 +
            0.3}s`;
        }
    });
    //汉堡按钮旋转动画
    burger_son.forEach((item,index) =>{
        item.classList.toggle('show')
    })
})